﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="JT_TitleAdd.aspx.cs" Inherits="JTicket.UI.JT_TitleAdd" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $.ajax({
                type: "get",
                url: "ThGetHandler.axd?Time=" + new Date(),
                success: function (msg) {
                    var arr = eval(msg.toString());
                    if (arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            $("#seTheater").append("<option value=" +
                    arr[i].ThCode + ">" + arr[i].ThName + "</option>");
                        }
                    }
                },
                error: function () { },
                async: false
            });
            $.ajax({
                type: "get",
                url: "TitleTypeHandler.axd?Time=" + new Date(),
                success: function (msg) {
                    var arr = eval(msg.toString());
                    if (arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            $("#seSort").append("<option value=" +
                    arr[i].CodeVal + ">" + arr[i].CodeNote + "</option>");
                        }
                    }
                },
                error: function () { },
                async: false
            });


            $.ajax({
                type: "get",
                url: "TitleGetModel.axd?TitleCode=" + TitleCode + "&Time=" + new Date(),
                success: function (msg) {
                    var arr = eval(msg);
                    $('#txtTitle').val(arr[0].Stitlename);
                    $('#txtTeam').val(arr[0].Steam);
                    $('#txtBegin').val(ChangeDateFormat(arr[0].Begindate));
                    $('#txtEnd').val(ChangeDateFormat(arr[0].EndDate));
                    $('#txtTilteNum').val(arr[0].TitleNum);
                    $('#txtactor').val(arr[0].Actor);
                    $('#txtarea').val(arr[0].StitleInfo);
                    $("#seTheater ").val(arr[0].Stheater);
                    $("#seSort ").val(arr[0].Stitlesort);
                    $("#SeStuts ").val(arr[0].note);
                },
                error: function () { isAlertError(); },
                async: false
            }); 

        });
        //修改
        function Update() { 
            if ($('#txtTitle').val() == "") {
                alert("请输入剧目名称"); $("#txtTitle").focus(); return false;
            }
            if ($('#txtTeam').val() == "") {
                alert("请输入演出单位"); $("#txtTeam").focus(); return false;
            }
            if ($('#txtBegin').val() == "") {
                alert("请输入演出开始时间"); $("#txtBegin").focus(); return false;
            }
            if ($('#txtEnd').val() == "") {
                alert("请输入演出结束时间"); $("#txtEnd").focus(); return false;
            }
            if ($('#seTheater').val() == "-1") {
                alert("请选择剧院名称"); $("#seTheater").focus(); return false;
            }
            if ($('#seSort').val() == "-1") {
                alert("请选择演出类别"); $("#seSort").focus(); return false;
            }
            if ($('#SeStuts').val() == "-1") {
                alert("请选择剧目状态"); $("#SeStuts").focus(); return false;
            }
            if ($('#titlecode').val() == "") {
                alert("请单击要修改的演出剧目"); return false;
            }
            var model = new JTicket.Model.D_TitleInfo();
            model.StitleCode = TitleCode;
            model.Stitlename = $("#txtTitle").val();
            model.Steam = $("#txtTeam").val();
            model.Stheater = $("#seTheater").find("option:selected").text();
            model.Stitlesort = $("#seSort").find("option:selected").text();
            model.StitleInfo = $('#txtarea').val();
            model.Begindate = $('#txtBegin').val();
            model.EndDate = $('#txtEnd').val();
            model.TitleNum = $('#txtTilteNum').val();
            model.ThCode = $('#seTheater').val();
            model.Actor = $('#txtactor').val();
            model.note = $('#SeStuts').val();
            $("#BtnUpdate").attr("disabled", "disabled");
            JTicket.UI.Service.JT_TitleSvc.Update(model,
                    function Success(Result) {
                        alert(Result);
                        $("#BtnUpdate").removeAttr("disabled");
                        window.location.href = "JT_TitleManager.aspx";
                    }, isAlertError);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<input type="hidden" id="titlecode" value="" runat="server" />
    <asp:ScriptManager ID="sm" runat="server">
        <Services>
            <asp:ServiceReference InlineScript="true" Path="~/Service/JT_TitleSvc.asmx" />
            <asp:ServiceReference InlineScript="true" Path="~/Service/JT_OperSvc.asmx" />
        </Services>
    </asp:ScriptManager>
    <table align="center" border="0" cellpadding="4" cellspacing="1" class="toptable grid"
        width="100%">
        <tr>
            <td class="category t2" height="25" width="100px">
                剧目修改
            </td>
            <td class="category" height="25">
                <input type="button" id="BtnUpdate" value="修  改" onclick="Update();" onmousemove="showBtnOver(this)"
                    onmouseout="showBtnOut(this)" class="submitMiniGreen" />
                    <input type="button" id="Button1" value="取  消" onclick="window.location.href ='JT_TitleManager.aspx';" onmousemove="showBtnOver(this)"
                    onmouseout="showBtnOut(this)" class="submitMiniGreen" />
            </td>
        </tr>
    </table>
    <table width="100%" border="0" bordercolordark="#3890B5" bordercolorlight="#6591BE"
        align="center" cellpadding="1" cellspacing="1">
        <tr>
            <td bgcolor="#f6f6f6" align="right" style="width: 100px">
                剧目名称：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="width: 240px">
                <input id="txtTitle" class="input" type="text" />
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                演出单位：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <input id="txtTeam" class="input" type="text" />
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px">
                上演时间起：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <input id="txtBegin" class="input" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                上演时间止：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <input id="txtEnd" class="input" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px; height: 30px;">
                场次：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="height: 30px">
                <input id="txtTilteNum" class="input" type="text" value="场次1" />
            </td>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px; height: 30px;">
                演出类别：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="height: 30px">
                <select id="seSort" name="D1">
                    <option value="-1">--选择演出类别--</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px">
                场馆：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <select id="seTheater" name="D1">
                    <option value="-1">--请选择场馆名称--</option>
                </select>
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                剧目状态：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <select id="SeStuts" name="D2">
                    <option value="-1">--选择剧目状态--</option>
                    <option value="1">正常</option>
                    <option value="0">锁定</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#f6f6f6" style="width: 100px">
                主要演员：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <textarea id="txtactor" class="textarea" cols="20" name="S2" style="height: 50px;
                    width: 300px;" rows="1"></textarea>
            </td>
            <td align="right" bgcolor="#f6f6f6" height="25" style="width: 100px">
                简介：
            </td>
            <td align="left" bgcolor="#f6f6f6">
                <textarea id="txtarea" class="textarea" cols="20" name="S1" style="height: 50px;
                    width: 300px;" rows="1"></textarea>
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#f6f6f6" style="width: 100px">
            </td>
            <td align="left" bgcolor="#f6f6f6">
            </td>
            <td align="center" bgcolor="#f6f6f6" height="25" style="width: 100px">
            </td>
            <td align="left" bgcolor="#f6f6f6">
            </td>
        </tr>
    </table>
</asp:Content>
